package com.example.mycarcalling.service.impl;

import com.example.mycarcalling.bean.Application;
import com.example.mycarcalling.bean.Navigation;
import com.example.mycarcalling.dao.ApplicationMapper;
import com.example.mycarcalling.service.ApplicationService;
import com.example.mycarcalling.utils.FileResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;

@Service("applicationService")
@Transactional(rollbackFor = Exception.class)
public class ApplicationServiceImpl implements ApplicationService {

    @Resource
    private ApplicationMapper applicationMapper;


    @Override
    public Long saveApplication(Application application) {

        if(null==application){
            return null;
        }
        Application application1 = null;
        try {
            application1 = applicationMapper.selectByDriverId(application.getApplicationUser());
            if(null == application1){
                applicationMapper.insertSelective(application);
                System.out.println("navigation.getNavigationId() :"+application.getId());
                return application.getId();
            }
            return null;

        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public Application getDriverApplication(Long driverId) {
        return applicationMapper.selectByDriverId(driverId);
    }
}
